/**********************************************
 * 	TestSentenceChecker.java				  *
 *  Course: CS3343							  *
 *  Version: 2.5    Release 3				  *
 *  Last Modified : 22 MAR 2013			      *
 **********************************************/
package testChecker;


import org.junit.Before;
import checker.SentenceChecker;
import org.junit.Test;
import junit.framework.TestCase;

public class TestSentenceChecker extends TestCase {

	@Before
	public void setUp() throws Exception {


	}

	//test whether the first word in the sentence starts with capital letter
	@Test
	public void testCapitalA(){
		SentenceChecker sentenceChecker = new SentenceChecker();
		boolean result = sentenceChecker.startWithCapital("I am a boy");
		assertEquals(true, result);
	}

	//test whether the first word in the sentence starts with capital letter
	@Test
	public void testCapitalB(){
		SentenceChecker sentenceChecker = new SentenceChecker();
		boolean result = sentenceChecker.startWithCapital("i am a boy");
		assertEquals(false, result);
	}


	//test whether the sentence ends with proper punctuation
	@Test
	public void testPunctuationA(){
		SentenceChecker sentenceChecker = new SentenceChecker();
		boolean result = sentenceChecker.endWithPunctuation("I am a boy!");
		assertEquals(true, result);
	}
	
	//test whether the sentence ends with proper punctuation
	@Test
	public void testPunctuationB(){
		SentenceChecker sentenceChecker = new SentenceChecker();
		boolean result = sentenceChecker.endWithPunctuation("I am a boy#");
		assertEquals(false, result);
	}

	//test whether the sentence ends with proper punctuation
	@Test
	public void testPunctuationC(){
		SentenceChecker sentenceChecker = new SentenceChecker();
		boolean result = sentenceChecker.endWithPunctuation("I am a boy");
		assertEquals(false, result);
	}


	//unit test of the SentenceChecker class, file IO is not included
	@Test
	public void testSentenceA(){

		class SentenceCheckerStub extends SentenceChecker{

			public boolean isCompleteSentence(String sentence){
				if (startWithCapital(sentence) && endWithPunctuation(sentence)) 
					return true;

				return false;
			}
		};

		SentenceCheckerStub sentenceCheckerStub = new SentenceCheckerStub();
		boolean result = sentenceCheckerStub.isCompleteSentence("I am a very good girl.");
		assertEquals(true, result);

	}
	
	//unit test of the SentenceChecker class, file IO is not included
	@Test
	public void testSentenceB(){

		class SentenceCheckerStub extends SentenceChecker{

			public boolean isCompleteSentence(String sentence){
				if (startWithCapital(sentence) && endWithPunctuation(sentence)) 
					return true;

				return false;
			}
		};

		SentenceCheckerStub sentenceCheckerStub = new SentenceCheckerStub();
		boolean result = sentenceCheckerStub.isCompleteSentence("i am a very good girl.");
		assertEquals(false, result);

	}
	
	//test integration with FileIO class that reads file contents for the SentenceChecker class
	@Test
	public void testIntegrationA(){
		SentenceChecker sentenceChecker = new SentenceChecker();
		boolean result = sentenceChecker.isCompleteSentence("article1.txt");
		assertEquals(true, result);
	}

	//test integration with FileIO class that reads file contents for the SentenceChecker class
	@Test
	public void testIntegrationB(){
		SentenceChecker sentenceChecker = new SentenceChecker();
		boolean result = sentenceChecker.isCompleteSentence("helloworld.txt");
		assertEquals(false, result);
	}
}


